package com.itheima.interceptor;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
/**
 * 环绕增强
 */
public class AroundInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Object result = null;
        try {
            System.out.println("前置增强");
            result = invocation.proceed();
            System.out.println("后置增强");
        } catch (Throwable throwable) {
            System.out.println("异常增强");
            throwable.printStackTrace();
        } finally {
            System.out.println("最终增强");
        }
        return result;
    }
}